<?php

namespace App\Http\Controllers\Mini;

use App\Http\Controllers\Controller;
use App\Models\HouseCate;
use App\Services\HouseCateService;
use App\Services\HouseService;
use Illuminate\Http\Request;

class HouseCateController extends Controller
{
    public $houseCate;

    /**
     * 构造方法
     * CartController constructor.
     */
    public function __construct()
    {
        $this->houseCate = new HouseCate();
    }

    /**
     * 获取分类列表
     * @param Request $request
     * @param $type
     * @return array
     * @author ypp
     * @date XXX
     */
    public function cateList(Request $request,$type)
    {
        $where['status'] = 1;
        $where['type'] = $type;
        return $this->success( $this->houseCate->getAll($where));
    }

    /**
     * @param Request $request
     * @param $type
     * @return array
     * @author ypp
     * @date XXX
     */
    public function getInfoList(Request $request,HouseCateService $houseCateService)
    {
        $res = $houseCateService->getInfoListByType();
        if($res['status']){
            return $this->success($res['data']);
        }else{
            return $this->error($res['msg']);
        }
    }

    /**
     * @param Request $request
     * @param $type
     * @return array
     * @author ypp
     * @date XXX
     */
    public function getInfoDetail(Request $request, HouseCateService $houseCateService, $type,$id)
    {
        $res = $houseCateService->getInfoDetailByType($type,$id);
        if($res['status']){
            return $this->success($res['data']);
        }else{
            return $this->error($res['msg']);
        }
    }

}
